/**
 *  @file multistateRepresentation.h
 *
 *  @date 16-nov-2009
 *  @author Ives van der Flaas
 */

#ifndef MULTISTATEREPRESENTATION_H_
#define MULTISTATEREPRESENTATION_H_

#include <vector>
#include <tr1/memory>
#include "representation.h"
#include "staticRepresentation.h"


namespace si
{

/**
 * The ID that will be used to identify individual states of a
 * MultistateRepresentation. Will be returned
 * by functions adding a new state and will be asked for by functions
 * that are changing state.
 */
typedef int StateID;

/**
 * A representation consisting of several states. States are StaticRepresentations.
 * This class is generic. States can be added and this object's current state
 * can be changed.
 */
class MultistateRepresentation: public si::Representation
{
public:
	/**
	 * This function will add a new state to the MultistateRep object.
	 * The current state will not be changed unless this is the
	 * first state added. In that case this will become the
	 * new state.
	 * @param newRep The representation te be added.
	 * @return The ID of the state you just added.
	 */
	StateID addState(std::tr1::shared_ptr<StaticRepresentation> newRep);

	/**
	 * Changes the object's internal state to newState. The old state
	 * will be returned.
	 * @param newState The state we are going to.
	 */
	StateID changeState(StateID newState);

	std::tr1::shared_ptr<si::StaticRepresentation> getState(si::StateID state);

	virtual void update(double time);
	virtual void draw(si::Vector2 virtualPosition, si::Vector2 virtualSize);
	virtual Vector2 getSize() const { return fRepresentations[fCurrentRepresentation]->getSize(); }

private:
	/**
	 * A list of all possible representations;
	 */
	std::vector<std::tr1::shared_ptr<StaticRepresentation> > fRepresentations;
	StateID fCurrentRepresentation;
};

}

#endif /* MULTISTATEREPRESENTATION_H_ */
